from time import sleep
from pages.server_page.login_page import LoginPage


# 实现登录逻辑
class LoginLogic(object):

    #后台登录
    def login(self,driver,username,password,verify_code='8888'):
        # 1. 输入用户名
        driver.find_element(*LoginPage.username_input).clear()
        driver.find_element(*LoginPage.username_input).send_keys(username)
        # 2. 输入密码
        driver.find_element(*LoginPage.password_input).clear()
        driver.find_element(*LoginPage.password_input).send_keys(password)
        # 3. 输入验证码
        driver.find_element(*LoginPage.verify_input).send_keys(verify_code)
        # 4. 点击登录按钮
        driver.find_element(*LoginPage.login_button).click()
        sleep(1)

    # 获取概览
    def get_overview_info(self,driver):
        driver.implicitly_wait(5)
        return driver.find_element(*LoginPage.overview_text).text



